package com.lebang.controller.webapi;

import com.lebang.entity.task.LbbSosoWithBLOBs;
import com.lebang.model.enums.Booleans;
import com.lebang.service.task.impl.SosoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: hwq
 * @Date: 2019/8/8 10:29
 * @Version 1.0
 */
@Controller
@RequestMapping("/web/api")
public class WebController {
    @Autowired
    private SosoServiceImpl sosoService;

    @GetMapping("/task/detaillist")
    public String detaillist() {
        return "/tasktemplate/detailList";
    }

    @GetMapping("/task/taskdetail")
    public String taskdetail(String taskId, String type, Model model) {
        if(type==null){
            type="common";
        }
        model.addAttribute("taskId", taskId);
        model.addAttribute("type", type.toLowerCase());
        switch (type.toLowerCase()) {
            case "common":
                return "/tasktemplate/taskDetail";
            case "soso":
                LbbSosoWithBLOBs soso = sosoService.taskInfoByTaskId(taskId);
                if (soso.getNeedCheck().equals(Booleans.False)) {
                    return "/tasktemplate/sosoDetail";
                } else {
                    return "/tasktemplate/checkSoso";
                }
            case "Comments":
                return "/tasktemplate/commentsDetail";

            default:
                break;
        }

        return "/tasktemplate/taskDetail";
    }

    @GetMapping("/task/tasklist")
    public String tasklist() {
        return "/tasktemplate/taskList";
    }

    @GetMapping("/task/comments")
    public String comments(String taskId, String type, Model model) {
        model.addAttribute("taskId", taskId);
        model.addAttribute("type", type);
        return "/tasktemplate/commentsDetail";
    }

    @GetMapping("/task/sosodetail")
    public String sosodetail(String taskId, String type, Model model) {
        model.addAttribute("taskId", taskId);
        model.addAttribute("type", type);
        return "/tasktemplate/sosoDetail";
    }
    @GetMapping("/task/checksoso")
    public String checksoso(String taskId, String type, Model model) {
        model.addAttribute("taskId", taskId);
        model.addAttribute("type", type);
        return "/tasktemplate/checkSoso";
    }
    @GetMapping("/task/sosolist")
    public String sosolist() {
        return "/tasktemplate/sosoList";
    }
}
